package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ybl
 * @date 2023/3/7 14:49
 * @description 教师-课程信息编辑接口
 * @since version-1.0
 */
@Api(value = "教师-课程接口", tags = "教师-课程信息编辑接口")
@RestController
public class CourseTeacherController {
    @Autowired
    private CourseTeacherService courseTeacherService;

    /**
     * @author ybl
     * @date 2023/3/7 14:50
     * @description 课程教师查询接口
     * @param id courseId
     * @return java.util.List<com.xuecheng.content.model.po.CourseTeacher>
     * @since version-1.0
     */
    @ApiOperation("课程教师查询接口")
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> getCourseTeacherList(@PathVariable Long id) {
        return courseTeacherService.getCourseTeacherList(id);
    }

    /**
     * @author ybl
     * @date 2023/3/7 15:04
     * @description 课程教师新增或修改接口
     * @param courseTeacher 新增或修改的教师数据
     * @return com.xuecheng.content.model.po.CourseTeacher
     * @since version-1.0
     */
    @ApiOperation("课程教师新增或修改接口")
    @PostMapping("/courseTeacher")
    public CourseTeacher saveCourseTeacher(@RequestBody CourseTeacher courseTeacher) {
        return courseTeacherService.saveCourseTeacher(courseTeacher);
    }

    /**
     * @author ybl
     * @date 2023/3/7 15:55
     * @description 课程教师删除接口
     * @param courseId 课程id
     * @param id 教师id
     * @since version-1.0
     */
    @ApiOperation("课程教师删除接口")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteCourseTeacher(@PathVariable Long courseId, @PathVariable Long id) {
        courseTeacherService.deleteCourseTeacher(courseId, id);
    }
}
